QueueMessage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A addCallback 0 3 1
A execute 0 4 1
1
/**
2
 *
3
 */
4
import {ModelInterface, ModelStaticInterface, QueueAble} from "../../../JeloquentInterfaces";
5
6
export default class QueueMessage implements QueueAble {
7
8
    private action: string;
9
10
    private callback: CallableFunction;
11
12
    private data: object|Array<object>;
13
14
    private model: ModelInterface|ModelStaticInterface;
15
16
    constructor(model: ModelInterface|ModelStaticInterface, action: string, data:object|Array<object>) {
17
        this.model = model;
18
        this.action = action;
19
        this.data = data;
20
        this.callback = () => null;
21
    }
22
23
    addCallback(callback: CallableFunction): void {
24
        this.callback = callback;
25
    }
26
27
    execute(): void {
28
        this.model[this.action](this.data);
29
        this.callback();
30
    }
31
}